
import 'package:dk_flutter_module_sale/phoenix/home/bean/home_contract_bean.dart';
import 'package:flutter/material.dart';
import '../../../r.dart';
import '../bean/ui_const_bean.dart';

class ContractItemWidget extends StatelessWidget {

  final bool hasLine;
  final bool isMax;//是否是最大值
  final ContractItemBean contractItemBean;

  ContractItemWidget(this.contractItemBean,this.hasLine,this.isMax);

  @override
  Widget build(BuildContext context) {
    return Container(
      width:  _calItemHeight() ,
      height: UIConstBean.ContractItemH,
      color: Colors.white,
      padding: EdgeInsets.only(top: 2),
      child:  hasLine ? _buildStatusLineWithLine() : _buildStatusLineWithNotLine(),
    );
  }
  double _calItemHeight() {
    if(hasLine) {
      return  isMax?  (UIConstBean.ContractItemWWithLine - 20) : UIConstBean.ContractItemWWithLine;
    }
    return UIConstBean.ContractItemW ;
  }

  Widget _buildStatusLineWithLine() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Image.asset((contractItemBean?.state == 1)? R.imagesHomeStausFinishPng : R.imagesHomeStausUnfinishPng,width: 19,height: 19,fit:BoxFit.contain,),
            Text(contractItemBean?.stateName,
              textAlign: TextAlign.center,
              style: TextStyle(color: (contractItemBean?.state == 1)?Color(0xff3DBCC6):Color(0xff999999), fontSize: 12,fontWeight: FontWeight.normal),
            ),
          ],
        ),
        Expanded(
          child:Container(
            color: Colors.white,
            child: Column(
              children: <Widget>[
                SizedBox(height: UIConstBean.ContractItemH/2 -15,),
                Container(
                  height: 1,
                  width: double.infinity,
                  color: Color(0xffC8D9E2),
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }

  Widget _buildStatusLineWithNotLine() {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Image.asset((contractItemBean?.state == 1)? R.imagesHomeStausFinishPng : R.imagesHomeStausUnfinishPng,width: 19,height: 19,fit:BoxFit.contain,),
        Text('待签约',
          textAlign: TextAlign.center,
          style: TextStyle(color: (contractItemBean?.state == 1)?Color(0xff3DBCC6):Color(0xff999999), fontSize: 12,fontWeight: FontWeight.normal),
        ),
      ],
    );
  }
}